package com.wsh.study.controller;

import com.wsh.study.model.ClassificationModel;
import com.wsh.study.model.DataHistoryESModel;
import com.wsh.study.service.DataHistoryESService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class InitController {

  @Autowired
  private DataHistoryESService dataHistoryESService;

  @ResponseBody
  @GetMapping("/")
  public List<DataHistoryESModel> hello(DataHistoryESModel model) {
    List<DataHistoryESModel> list = dataHistoryESService.query(model);
    return list;
  }

  @ResponseBody
  @GetMapping("/tab")
  public List<ClassificationModel> tab() {
    String[] str = new String[]{"学习中心", "编程比赛", "学习技巧", "帮助文档"};
    List<ClassificationModel> list = new ArrayList<>();
    for (String s : str) {
      ClassificationModel model = new ClassificationModel();
      model.setName(s);
      model.setLink("http://www.baidu.com");
    }
    return list;
  }

  @ResponseBody
  @GetMapping("/title")
  public List<ClassificationModel> title() {
    String[] str = new String[]{"全部课程", "开学必做", "主修课程", "选修课程"};
    List<ClassificationModel> list = new ArrayList<>();
    for (String s : str) {
      ClassificationModel model = new ClassificationModel();
      model.setName(s);
      model.setLink("http://www.baidu.com");
    }
    return list;
  }
}
